
local zhuhai = fk.CreateSkill{
  name = "mini__zhuhai",
}

Fk:loadTranslationTable{
  ["mini__zhuhai"] = "诛害",
  [":mini__zhuhai"] = "其他角色的结束阶段，若其本回合造成过伤害，你可以弃置一张牌，视为对其使用一张无距离限制的【杀】。",

  ["#mini__zhuhai-invoke"] = "诛害：你可以弃置一张牌，视为对 %dest 使用【杀】",

  ["$mini__zhuhai1"] = "善恶有报，天道轮回！",
  ["$mini__zhuhai2"] = "早知今日，何必当初！",
}

zhuhai:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player ~= target and player:hasSkill(zhuhai.name) and target.phase == Player.Finish and
      #player.room.logic:getActualDamageEvents(1, function(e)
        return e.data.from == target
      end, Player.HistoryTurn) > 0 and
      player:canUseTo(Fk:cloneCard("slash"), target, { bypass_distances = true, bypass_times = true }) and not player:isNude()
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local card = room:askToDiscard(player, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = zhuhai.name,
      prompt = "#mini__zhuhai-invoke::"..target.id,
      cancelable = true,
      skip = true,
    })
    if #card > 0 then
      event:setCostData(self, {tos = {target}, cards = card})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(event:getCostData(self).cards, zhuhai.name, player, player)
    if not target.dead then
      room:useVirtualCard("slash", nil, player, target, zhuhai.name, true)
    end
  end,
})

return zhuhai
